<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,IE=9,chrome=1"><meta name="generator" content="MATLAB 2021b"><title>Work with Basic ROS Messages</title><style type="text/css">.rtcContent { padding: 30px; } .S0 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 28.8px; min-height: 0px; white-space: pre-wrap; color: rgb(213, 80, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 24px; font-weight: 400; text-align: left;  }
.S1 { margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;  }
.S2 { margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left;  }
.CodeBlock { background-color: #F7F7F7; margin: 10px 0 10px 0;}
.S3 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 0px none rgb(0, 0, 0); border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S4 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 0px; padding: 0px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S5 { color: rgb(64, 64, 64); padding: 10px 0px 6px 17px; background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; overflow-x: hidden; line-height: 17.234px;  }
/* Styling that is common to warnings and errors is in diagnosticOutput.css */.embeddedOutputsErrorElement {    min-height: 18px;    max-height: 550px;}
.embeddedOutputsErrorElement .diagnosticMessage-errorType {    overflow: auto;}
.embeddedOutputsErrorElement.inlineElement {}
.embeddedOutputsErrorElement.rightPaneElement {}
/* Styling that is common to warnings and errors is in diagnosticOutput.css */.embeddedOutputsWarningElement {    min-height: 18px;    max-height: 550px;}
.embeddedOutputsWarningElement .diagnosticMessage-warningType {    overflow: auto;}
.embeddedOutputsWarningElement.inlineElement {}
.embeddedOutputsWarningElement.rightPaneElement {}
/* Copyright 2015-2019 The MathWorks, Inc. *//* In this file, styles are not scoped to rtcContainer since they could be in the Dojo Tooltip */.diagnosticMessage-wrapper {    font-family: Menlo, Monaco, Consolas, "Courier New", monospace;    font-size: 12px;}
.diagnosticMessage-wrapper.diagnosticMessage-warningType {    color: rgb(255,100,0);}
.diagnosticMessage-wrapper.diagnosticMessage-warningType a {    color: rgb(255,100,0);    text-decoration: underline;}
.diagnosticMessage-wrapper.diagnosticMessage-errorType {    color: rgb(230,0,0);}
.diagnosticMessage-wrapper.diagnosticMessage-errorType a {    color: rgb(230,0,0);    text-decoration: underline;}
.diagnosticMessage-wrapper .diagnosticMessage-messagePart,.diagnosticMessage-wrapper .diagnosticMessage-causePart {    white-space: pre-wrap;}
.diagnosticMessage-wrapper .diagnosticMessage-stackPart {    white-space: pre;}
.embeddedOutputsTextElement,.embeddedOutputsVariableStringElement {    white-space: pre;    word-wrap:  initial;    min-height: 18px;    max-height: 550px;}
.embeddedOutputsTextElement .textElement,.embeddedOutputsVariableStringElement .textElement {    overflow: auto;}
.textElement,.rtcDataTipElement .textElement {    padding-top: 3px;}
.embeddedOutputsTextElement.inlineElement,.embeddedOutputsVariableStringElement.inlineElement {}
.inlineElement .textElement {}
.embeddedOutputsTextElement.rightPaneElement,.embeddedOutputsVariableStringElement.rightPaneElement {    min-height: 16px;}
.rightPaneElement .textElement {    padding-top: 2px;    padding-left: 9px;}
.S6 { margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;  }
.S7 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 4px; padding: 6px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S8 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 4px 4px 0px 0px; padding: 6px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S9 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left;  }
.S10 { margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;  }
.S11 { margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;  }
.S12 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 0px; padding: 6px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.embeddedOutputsVariableTableElement .ClientViewDiv  table tr {  height: 22px;  white-space: nowrap;}
.embeddedOutputsVariableTableElement .ClientViewDiv  table tr td,.embeddedOutputsVariableTableElement .ClientViewDiv  table tr th {  background-color:white;  text-overflow: ellipsis;  font-family: 'Arial', sans-serif;  font-size: 12px;  overflow : hidden;}
.embeddedOutputsVariableTableElement .ClientViewDiv  table tr span {  text-overflow: ellipsis;  padding: 3px;}
.embeddedOutputsVariableTableElement .ClientViewDiv  table tr th {    color: rgba(0,0,0,0.5);  padding: 3px;  font-size: 9px;}</style></head><body><div class = rtcContent><h1  class = 'S0'><span>Work with Basic ROS Messages</span></h1><div  class = 'S1'><span>消息Messages是ROS中交换数据的主要容器。话题Topics和服务services使用消息messages在节点nodes之间传输数据。（有关主题和服务的更多信息，请参阅与</span><a href = "docid:ros_ug.mw_fa34dc6f-351e-4ab5-8680-46563496814b"><span>Exchange Data with ROS Publishers and Subscribers</span></a><span> and </span><a href = "docid:ros_ug.mw_70dbf089-5821-4e67-b96f-f659aea10c0c"><span>Call and Provide ROS Services</span></a><span>）</span></div><div  class = 'S1'><span>为了标识其数据结构，每个消息都有一个</span><span style=' font-style: italic;'>message type</span><span>。例如，来自激光扫描仪的传感器数据通常以</span><span style=' font-family: monospace;'>sensor_msgs/LaserScan</span><span>类型的消息发送。每个消息类型标识消息中包含的数据元素。每个消息类型名称都是包名称、后跟正斜杠 / 和类型名称的组合：</span></div><div  class = 'S1'><img class = "imageNode" src = "" width = "300" height = "180" alt = "" style = "vertical-align: baseline; width: 300px; height: 180px;"></img></div><div  class = 'S1'><span>MATLAB®支持机器人应用程序中常见的许多ROS消息类型。这个例子展示了在MATLAB中创建、探索和填充ROS消息的一些方法。</span></div><div  class = 'S1'><span>先验知识:</span><span> </span><a href = "docid:ros_ug.mw_cb3fdf75-613d-45b1-90e1-aad102b9a24a"><span>Get Started with ROS</span></a><span>,</span><span> </span><a href = "docid:ros_ug.mw_d625a603-7f37-4925-9470-2de734937434"><span>Connect to a ROS Network</span></a></div><h2  class = 'S2'><span>Find Message Types</span></h2><div  class = 'S1'><span>初始化ROS master 和全局节点。</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S3'><span style="white-space: pre"><span >clear,clc,close </span><span style="color: rgb(170, 4, 249);">all</span><span >;</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S4'><span style="white-space: pre"><span >rosinit</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="5DA4C8BD" data-testid="output_0" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="61" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">Launching ROS Core...
...........Done in 4.7331 seconds.
Initializing ROS master on http://192.168.118.1:11311.
Initializing global node /matlab_global_node_35876 with NodeURI http://LAPTOP-TG3AQJDL:14907/</div></div></div></div></div><div  class = 'S6'><span>使用示例 </span><span style=' font-family: monospace;'>exampleHelperROSCreateSampleNetwork </span><span>向ROS网络填充三个附加节点以及示例发布者publishers和订阅者subscribers。</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: pre"><span >exampleHelperROSCreateSampleNetwork</span></span></div></div></div><div  class = 'S6'><span>网络上有各种各样的节点，有一些主题和附属的发布者和订阅者。</span></div><div  class = 'S1'><span>You can see the full list of available topics by calling </span><span style=' font-family: monospace;'></span><a href = "docid:ros_ref.bupf5_j_14"><span style=' font-family: monospace;'>rostopic</span></a><span style=' font-family: monospace;'> list</span><span>.</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >rostopic </span><span style="color: rgb(170, 4, 249);">list</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="F8F04476" data-testid="output_1" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="61" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">/pose  
/rosout
/scan  
/tf    </div></div></div></div></div><div  class = 'S6'><span>如果您想进一步了解通过</span><span style=' font-family: monospace;'>/scan</span><span> 话题发送的数据类型，请使用</span><span style=' font-family: monospace;'>rostopic info</span><span>命令来检查它。</span><span style=' font-family: monospace;'>/scan</span><span> 具有</span><span style=' font-family: monospace;'>sensor_msgs/LaserScan</span><span>的消息类型。</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >rostopic </span><span style="color: rgb(170, 4, 249);">info /scan</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="633A507F" data-testid="output_2" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="118" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">Type: sensor_msgs/LaserScan
 
Publishers:
* /node_3 (http://LAPTOP-TG3AQJDL:14925/)
 
Subscribers:
* /node_1 (http://LAPTOP-TG3AQJDL:14913/)
* /node_2 (http://LAPTOP-TG3AQJDL:14919/)</div></div></div></div></div><div  class = 'S6'><span>命令输出还告诉您哪些节点正在发布和订阅话题。 了解发布者和订阅者, see</span><span> </span><a href = "docid:ros_ug.mw_70dbf089-5821-4e67-b96f-f659aea10c0c"><span>Exchange Data with ROS Publishers and Subscribers</span></a><span>.</span></div><div  class = 'S1'><span>要了解有关主题消息类型的更多信息，请使用 </span><a href = "docid:ros_ref.bupf5_j_2"><span style=' font-family: monospace;'>rosmessage</span></a><span>函数创建同一类型的空消息。</span><span style=' font-family: monospace;'>rosmessage</span><span>支持消息类型的制表符完成。要完成消息类型名称，请键入要完成的名称的前几个字符，然后按</span><span style=' font-weight: bold;'>Tab</span><span>键。</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >scandata = rosmessage(</span><span style="color: rgb(170, 4, 249);">'sensor_msgs/LaserScan'</span><span >)</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="A6249AF0" data-testid="output_3" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="237" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">scandata = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  ROS LaserScan message with properties:

       MessageType: 'sensor_msgs/LaserScan'
            Header: [1×1 Header]
          AngleMin: 0
          AngleMax: 0
    AngleIncrement: 0
     TimeIncrement: 0
          ScanTime: 0
          RangeMin: 0
          RangeMax: 0
            Ranges: [0×1 single]
       Intensities: [0×1 single]

  Use showdetails to show the contents of the message
</div></div></div></div></div></div><div  class = 'S6'><span>创建的消息 </span><span style=' font-family: monospace;'>scandata </span><span>通常具有许多与从激光扫描仪接收的数据相关的属性。例如，最小感应距离存储在</span><span style=' font-family: monospace;'>RangeMin</span><span>属性中，最大感应距离存储在</span><span style=' font-family: monospace;'>RangeMax</span><span>中。</span></div><div  class = 'S1'><span>要查看主题和服务可用的所有消息类型的完整列表，请使用</span><a href = "docid:ros_ref.bupf5_j_3"><span style=' font-family: monospace;'>rosmsg</span></a><span style=' font-family: monospace;'> list</span><span>。</span></div><h2  class = 'S9'><span>Explore Message Structure and Get Message Data</span></h2><div  class = 'S1'><span>ROS消息messages是对象objects，消息数据存储在属性中。MATLAB具有查找和探索消息内容的方便方法。</span></div><ul  class = 'S10'><li  class = 'S11'><span>如果订阅 </span><span style=' font-family: monospace;'>/pose</span><span>主 题，则可以接收和检查发送的消息。</span></li></ul><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >posesub = rossubscriber(</span><span style="color: rgb(170, 4, 249);">'/pose'</span><span >)</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="858CDC69" data-testid="output_4" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="122" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">posesub = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  Subscriber - 属性:

        TopicName: '/pose'
    LatestMessage: [0×1 Twist]
      MessageType: 'geometry_msgs/Twist'
       BufferSize: 1
    NewMessageFcn: []
</div></div></div></div></div></div><div  class = 'S6'><span>使用</span><a href = "docid:ros_ref.buqbyro"><span style=' font-family: monospace;'>receive</span></a><span> 从订阅者获取数据。一旦收到新消息，函数将返回该消息并将其存储在</span><span style=' font-family: monospace;'>posedata</span><span>变量中（第二个参数以秒为单位超时）。</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >posedata = receive(posesub, 10)</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="EB8309E1" data-testid="output_5" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="122" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">posedata = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  ROS Twist message with properties:

    MessageType: 'geometry_msgs/Twist'
         Linear: [1×1 Vector3]
        Angular: [1×1 Vector3]

  Use showdetails to show the contents of the message
</div></div></div></div></div></div><div  class = 'S6'><span>该消息具有 </span><span style=' font-family: monospace;'>geometry_msgs/Twist</span><span>类型。消息中还有两个其他属性：</span><span style=' font-family: monospace;'>Linear</span><span> and </span><span style=' font-family: monospace;'>Angular</span><span>。通过直接访问这些消息属性，可以看到它们的值：</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >posedata.Linear</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="1A2E7A5E" data-testid="output_6" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="136" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">ans = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  ROS Vector3 message with properties:

    MessageType: 'geometry_msgs/Vector3'
              X: 0.3619
              Y: 0.6654
              Z: 0.7190

  Use showdetails to show the contents of the message
</div></div></div></div></div></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >posedata.Angular</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="21D5AF03" data-testid="output_7" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="136" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">ans = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  ROS Vector3 message with properties:

    MessageType: 'geometry_msgs/Vector3'
              X: -0.5268
              Y: 0.0624
              Z: 0.0771

  Use showdetails to show the contents of the message
</div></div></div></div></div></div><div  class = 'S6'><span>这些消息字段的每个值实际上都是消息本身。它们的消息类型是</span><span style=' font-family: monospace;'>geometry_msgs/Vector3</span><span>。</span><span style=' font-family: monospace;'>geometry_msgs/Twist</span><span>是由两条</span><span style=' font-family: monospace;'>geometry_msgs/Vector3</span><span>消息组成的复合消息。</span></div><div  class = 'S1'><span>这些嵌套消息的数据访问与访问其他消息中的数据完全相同。使用以下命令访问线性</span><span style=' font-family: monospace;'>Linear</span><span>消息的X组件：</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >xpos = posedata.Linear.X</span></span></div><div  class = 'S5'><div class='variableElement' style='font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12px; '>xpos = 0.3619</div></div></div></div><div  class = 'S1'><span>如果要快速摘要消息中包含的所有数据，请调用</span><a href = "docid:ros_ref.buqb0sj"><span style=' font-family: monospace;'>showdetails</span></a><span> 函数。showdetails可处理任何类型的消息，并递归显示所有消息数据属性。</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >showdetails(posedata)</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="4596334B" data-testid="output_9" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="118" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  Linear     
    X :  0.3618614072765207
    Y :  0.665350368423266
    Z :  0.7189952326409099
  Angular    
    X :  -0.526813286570587
    Y :  0.06241787011561017
    Z :  0.07706711275532224</div></div></div></div></div><div  class = 'S6'><span style=' font-family: monospace;'>showdetails</span><span> 在调试期间以及希望快速浏览消息message内容时帮助您。</span></div><h2  class = 'S9'><span>Set Message Data</span></h2><div  class = 'S1'><span>你也可以设置消息属性值。使用</span><span style=' font-family: monospace;'>eometry_msgs/Twist</span><span>类型创建消息。</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >twist = rosmessage(</span><span style="color: rgb(170, 4, 249);">'geometry_msgs/Twist'</span><span >)</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="BA5CDAC5" data-testid="output_10" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="122" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">twist = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  ROS Twist message with properties:

    MessageType: 'geometry_msgs/Twist'
         Linear: [1×1 Vector3]
        Angular: [1×1 Vector3]

  Use showdetails to show the contents of the message
</div></div></div></div></div></div><div  class = 'S6'><span>默认情况下，此消息的数值属性初始化为0。您可以修改此邮件的任何属性。将</span><span style=' font-family: monospace;'>Linear</span><span>.Y项设置为5。</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: pre"><span >twist.Linear.Y = 5;</span></span></div></div></div><div  class = 'S1'><span>查看消息数据以确保更改生效。</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >twist.Linear</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="F93FC7CA" data-testid="output_11" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="136" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">ans = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  ROS Vector3 message with properties:

    MessageType: 'geometry_msgs/Vector3'
              X: 0
              Y: 5
              Z: 0

  Use showdetails to show the contents of the message
</div></div></div></div></div></div><div  class = 'S6'><span>一旦消息填充了您的数据，您就可以将其用于发布者、订阅者和服务。See the</span><span> </span><a href = "docid:ros_ug.mw_fa34dc6f-351e-4ab5-8680-46563496814b"><span>Exchange Data with ROS Publishers and Subscribers</span></a><span> and</span><span> </span><a href = "docid:ros_ug.mw_70dbf089-5821-4e67-b96f-f659aea10c0c"><span>Call and Provide ROS Services</span></a><span> examples.</span></div><h2  class = 'S9'><span>Copy Messages</span></h2><div  class = 'S1'><span>复制消息message内容有两种方法：</span></div><ul  class = 'S10'><li  class = 'S11'><span>您可以创建引用副本</span><span style=' font-style: italic;'>reference copy</span><span>，而原始message共享相同的数据。</span></li><li  class = 'S11'><span>你可以创建一个深副本</span><span style=' font-style: italic;'>deep copy</span><span>。副本和原始消息都有自己的数据的深层副本。</span></li></ul><div  class = 'S1'><span>如果要在不同的函数或对象之间共享消息数据，则引用副本reference copy很有用，而如果需要消息的独立引用independent copy，则需要深拷贝。</span></div><div  class = 'S1'><span>使用=符号制作消息的引用副本</span><span style=' font-style: italic;'>reference copy</span><span>。这将创建一个引用与原始变量相同的消息内容的变量。</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >twistCopyRef = twist</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="25ACC941" data-testid="output_12" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="122" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">twistCopyRef = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  ROS Twist message with properties:

    MessageType: 'geometry_msgs/Twist'
         Linear: [1×1 Vector3]
        Angular: [1×1 Vector3]

  Use showdetails to show the contents of the message
</div></div></div></div></div></div><div  class = 'S1'><span>修改</span><span style=' font-family: monospace;'>twistCopyRef</span><span>的</span><span style=' font-family: monospace;'>Linear.Z</span><span>字段。这也会更改</span><span style=' font-family: monospace;'>twist</span><span>的内容。</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S3'><span style="white-space: pre"><span >twistCopyRef.Linear.Z = 7;</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S4'><span style="white-space: pre"><span >twist.Linear</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="12D44508" data-testid="output_13" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="136" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">ans = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  ROS Vector3 message with properties:

    MessageType: 'geometry_msgs/Vector3'
              X: 0
              Y: 5
              Z: 7

  Use showdetails to show the contents of the message
</div></div></div></div></div></div><div  class = 'S1'><span>制作</span><span style=' font-family: monospace;'>twist</span><span>的深层副本deep copy，以便在不影响原始数据的情况下更改其内容。使用</span><span style=' font-family: monospace;'>copy函数</span><span>生成新消息</span><span style=' font-family: monospace;'>twistCopyDeep</span><span>：</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >twistCopyDeep = copy(twist)</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="88086D7E" data-testid="output_14" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="122" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">twistCopyDeep = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  ROS Twist message with properties:

    MessageType: 'geometry_msgs/Twist'
         Linear: [1×1 Vector3]
        Angular: [1×1 Vector3]

  Use showdetails to show the contents of the message
</div></div></div></div></div></div><div  class = 'S1'><span>修改</span><span style=' font-family: monospace;'>twistCopyDeep</span><span>的 </span><span style=' font-family: monospace;'>Linear.X</span><span> 属性。</span><span style=' font-family: monospace;'>twist</span><span>的内容保持不变。</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S3'><span style="white-space: pre"><span >twistCopyDeep.Linear.X = 100;</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S4'><span style="white-space: pre"><span >twistCopyDeep.Linear</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="1697F500" data-testid="output_15" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="136" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">ans = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  ROS Vector3 message with properties:

    MessageType: 'geometry_msgs/Vector3'
              X: 100
              Y: 5
              Z: 7

  Use showdetails to show the contents of the message
</div></div></div></div></div><div class="inlineWrapper outputs"><div  class = 'S12'><span style="white-space: pre"><span >twist.Linear</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="801D2725" data-testid="output_16" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="136" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">ans = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  ROS Vector3 message with properties:

    MessageType: 'geometry_msgs/Vector3'
              X: 0
              Y: 5
              Z: 7

  Use showdetails to show the contents of the message
</div></div></div></div></div></div><h2  class = 'S9'><span>Save and Load Messages</span></h2><div  class = 'S1'><span>您可以保存messages并存储内容以供以后使用。</span></div><div  class = 'S1'><span>从订阅者subscriber获取新消息message。</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >posedata = receive(posesub,10)</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="521EA841" data-testid="output_17" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="122" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">posedata = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  ROS Twist message with properties:

    MessageType: 'geometry_msgs/Twist'
         Linear: [1×1 Vector3]
        Angular: [1×1 Vector3]

  Use showdetails to show the contents of the message
</div></div></div></div></div></div><div  class = 'S6'><span>使用MATLAB的Save函数将姿势数据保存到MAT文件中。</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: pre"><span >save(</span><span style="color: rgb(170, 4, 249);">'posedata.mat'</span><span >,</span><span style="color: rgb(170, 4, 249);">'posedata'</span><span >)</span></span></div></div></div><div  class = 'S1'><span>在将文件加载回工作区之前，请清除posedata变量。</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: pre"><span >clear </span><span style="color: rgb(170, 4, 249);">posedata</span></span></div></div></div><div  class = 'S1'><span>现在可以通过调用</span><a href = "docid:matlab_ref.btm0etn-1"><span style=' font-family: monospace;'>load</span></a><span> 函数来加载消息数据。这将</span><span style=' font-family: monospace;'>posedata</span><span>从上面加载到</span><span style=' font-family: monospace;'>messageData</span><span>结构中。</span><span style=' font-family: monospace;'>posedata</span><span>是结构的数据字段。</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >messageData = load(</span><span style="color: rgb(170, 4, 249);">'posedata.mat'</span><span >)</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="F0B778A8" data-testid="output_18" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="35" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">messageData = <span class="headerElement" style="white-space: pre; font-style: italic; color: rgb(179, 179, 179); font-size: 12px;">包含以下字段的 struct:</span></span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">    posedata: [1×1 Twist]
</div></div></div></div></div></div><div  class = 'S1'><span>检查 </span><span style=' font-family: monospace;'>messageData.posedata</span><span>以查看消息内容。</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >messageData.posedata</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="C79535AD" data-testid="output_19" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="122" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">ans = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  ROS Twist message with properties:

    MessageType: 'geometry_msgs/Twist'
         Linear: [1×1 Vector3]
        Angular: [1×1 Vector3]

  Use showdetails to show the contents of the message
</div></div></div></div></div></div><div  class = 'S1'><span>你现在可以删除MAT文件。</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: pre"><span >delete(</span><span style="color: rgb(170, 4, 249);">'posedata.mat'</span><span >)</span></span></div></div></div><h2  class = 'S9'><span>Object Arrays in Messages</span></h2><div  class = 'S1'><span>一些来自ROS的消息存储在对象数组</span><a href = "docid:matlab_doccenter.buwib_4-1"><span>object arrays</span></a><span>中。必须以不同于典型数据数组的方式处理这些数据。</span></div><div  class = 'S1'><span>在您的工作区中，变量</span><span style=' font-family: monospace;'>tf</span><span>包含一个示例消息。（</span><span style=' font-family: monospace;'>exampleHelperROSCreateSampleNetwork</span><span>脚本创建了变量。）在本例中，它是用于坐标转换的</span><span style=' font-family: monospace;'>tf/tfMessage</span><span>类型的消息。</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >tf</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="46B3CCF7" data-testid="output_20" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="107" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">tf = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  ROS tfMessage message with properties:

    MessageType: 'tf/tfMessage'
     Transforms: [53×1 TransformStamped]

  Use showdetails to show the contents of the message
</div></div></div></div></div></div><div  class = 'S6'><span style=' font-family: monospace;'>tf</span><span>有两个字段：</span><span style=' font-family: monospace;'>MessageType</span><span>包含标准数据数组，</span><span style=' font-family: monospace;'>Transforms</span><span>包含对象数组。有53个对象存储在转换</span><span style=' font-family: monospace;'>Transforms</span><span>中，并且它们都具有相同的结构。</span></div><div  class = 'S1'><span>在</span><span style=' font-family: monospace;'>Transforms</span><span>中展开</span><span style=' font-family: monospace;'>tf</span><span>以查看结构：</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >tf.Transforms</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="B86C3E55" data-testid="output_21" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="107" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">ans = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  53×1 ROS TransformStamped message array with properties:

    MessageType
    Header
    Transform
    ChildFrameId
</div></div></div></div></div></div><div  class = 'S6'><span>变换</span><span style=' font-family: monospace;'>Transforms</span><span>中的每个对象都有四个属性。可以展开以查看变换的变换字段。 You can expand to see the</span><span> </span><span style=' font-family: monospace;'>Transform</span><span> field of</span><span> </span><span style=' font-family: monospace;'>Transforms</span><span>.</span></div><div  class = 'S1'><span style=' font-family: monospace;'>    tformFields = tf.Transforms.Transform</span></div><div  class = 'S1'><span> </span><span style=' font-weight: bold;'>注意：</span><span>命令输出返回53个单独的答案，因为每个对象都被计算并返回其转换</span><span style=' font-family: monospace;'>Transform</span><span>字段的值。此格式并不总是有用的，因此可以使用以下命令将其转换为元胞数组cell array：</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >cellTransforms = {tf.Transforms.Transform}</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableTableElement" uid="E8DC95E4" data-testid="output_22" style="width: calc(100% - 5px);"><div class="ClientDocument veSpecifier table DataFitToViewport" id="variableeditor_client_Document_0" widgetid="variableeditor_client_Document_0" tabindex="0"><div class="summaryBar" style="font-size: 12px; font-family: Consolas, Inconsolata, Menlo, monospace;"><span>cellTransforms = </span><span style="color: rgb(179, 179, 179); font-style: normal;">1×53 cell </span></div><div id="variableeditor_TableViewModel_0" widgetid="variableeditor_TableViewModel_0" class="cell ClientViewDiv hasSummaryBar" data-viewid="__1" style="width: 100%; overflow: auto;"><table cellspacing="0" style="border-spacing: 0px; border-collapse: collapse;"><thead><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; text-align: left; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>&nbsp;</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>1</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>2</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>3</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>4</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>5</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>6</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>7</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>8</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>9</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>10</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>11</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>12</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>13</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>14</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>15</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>16</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>17</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>18</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>19</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>20</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>21</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>22</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>23</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>24</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>25</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>26</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>27</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>28</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>29</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>30</span></th></tr></thead><tbody><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>1</span></th><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;"><span>1×1&nbsp;Transform</span></td></tr></tbody></table></div></div></div></div></div></div><div  class = 'S6'><span>这会将所有53个对象项放入元胞数组中，使您能够通过索引访问它们。</span></div><div  class = 'S1'><span>此外，您可以访问对象object数组元素，就像访问标准的MATLAB向量一样：</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >tf.Transforms(5)</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="AAAE52FE" data-testid="output_23" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="136" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">ans = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  ROS TransformStamped message with properties:

     MessageType: 'geometry_msgs/TransformStamped'
          Header: [1×1 Header]
       Transform: [1×1 Transform]
    ChildFrameId: '/imu_link'

  Use showdetails to show the contents of the message
</div></div></div></div></div></div><div  class = 'S1'><span>访问列表53中第五个transform的平移组件：</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >tf.Transforms(5).Transform.Translation</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="BA6E4285" data-testid="output_24" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="136" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">ans = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">  ROS Vector3 message with properties:

    MessageType: 'geometry_msgs/Vector3'
              X: 0.0599
              Y: 0
              Z: -0.0141

  Use showdetails to show the contents of the message
</div></div></div></div></div></div><h2  class = 'S9'><span>Shut Down ROS Network</span></h2><div  class = 'S1'><span>从ROS网络中删除示例节点、发布者和订阅者。</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: pre"><span >exampleHelperROSShutDownSampleNetwork</span></span></div></div></div><div  class = 'S6'><span>关闭ROS master并删除全局节点global node。</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S8'><span style="white-space: pre"><span >rosshutdown</span></span></div><div  class = 'S5'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="C3522CB6" data-testid="output_25" style="width: 716px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement eoOutputContent" data-width="686" data-height="32" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">Shutting down global node /matlab_global_node_35876 with NodeURI http://LAPTOP-TG3AQJDL:14907/
Shutting down ROS master on http://192.168.118.1:11311.</div></div></div></div></div><h2  class = 'S9'><span>Next Steps</span></h2><ul  class = 'S10'><li  class = 'S11'><span>See</span><span> </span><a href = "docid:ros_ug.mw_f993bbbe-25de-434f-bfd0-e5243256b23c"><span>Work with Specialized ROS Messages</span></a><span> for examples of handling images, point clouds, and laser scan messages.</span></li><li  class = 'S11'><span>For application examples, see the</span><span> </span><a href = "docid:ros_ug#mw_9c45a664-ab3d-48a5-a65a-52913b8532b5"><span>Get Started with Gazebo and a Simulated TurtleBot</span></a><span> or</span><span> </span><a href = "docid:ros_ug.mw_c9b2d3c3-0e9c-4222-8294-1453212e9813"><span>Get Started with a Real TurtleBot</span></a><span> examples.</span></li></ul><div  class = 'S1'><span style=' font-style: italic;'>Copyright 2014-2016 The MathWorks, Inc.</span></div><div  class = 'S1'></div>
<br>
<!-- 
##### SOURCE BEGIN #####
%% Work with Basic ROS Messages
% 消息Messages是ROS中交换数据的主要容器。话题Topics和服务services使用消息messages在节点nodes之间传输数据。（有关主题和服务的更多信息，请参阅与<docid:ros_ug.mw_fa34dc6f-351e-4ab5-8680-46563496814b 
% Exchange Data with ROS Publishers and Subscribers> and <docid:ros_ug.mw_70dbf089-5821-4e67-b96f-f659aea10c0c 
% Call and Provide ROS Services>）
% 
% 为了标识其数据结构，每个消息都有一个_message type_。例如，来自激光扫描仪的传感器数据通常以|sensor_msgs/LaserScan|类型的消息发送。每个消息类型标识消息中包含的数据元素。每个消息类型名称都是包名称、后跟正斜杠 
% / 和类型名称的组合：
% 
% 
% 
% MATLAB®支持机器人应用程序中常见的许多ROS消息类型。这个例子展示了在MATLAB中创建、探索和填充ROS消息的一些方法。
% 
% 先验知识: <docid:ros_ug.mw_cb3fdf75-613d-45b1-90e1-aad102b9a24a Get Started with 
% ROS>, <docid:ros_ug.mw_d625a603-7f37-4925-9470-2de734937434 Connect to a ROS 
% Network>
%% Find Message Types
% 初始化ROS master 和全局节点。

clear,clc,close all;
rosinit
%% 
% 使用示例 |exampleHelperROSCreateSampleNetwork| 向ROS网络填充三个附加节点以及示例发布者publishers和订阅者subscribers。

exampleHelperROSCreateSampleNetwork
%% 
% 网络上有各种各样的节点，有一些主题和附属的发布者和订阅者。
% 
% You can see the full list of available topics by calling <docid:ros_ref.bupf5_j_14 
% |rostopic|> |list|.

rostopic list
%% 
% 如果您想进一步了解通过|/scan| 话题发送的数据类型，请使用|rostopic info|命令来检查它。|/scan| 具有|sensor_msgs/LaserScan|的消息类型。

rostopic info /scan
%% 
% 命令输出还告诉您哪些节点正在发布和订阅话题。 了解发布者和订阅者, see <docid:ros_ug.mw_70dbf089-5821-4e67-b96f-f659aea10c0c 
% Exchange Data with ROS Publishers and Subscribers>.
% 
% 要了解有关主题消息类型的更多信息，请使用 <docid:ros_ref.bupf5_j_2 |rosmessage|>函数创建同一类型的空消息。|rosmessage|支持消息类型的制表符完成。要完成消息类型名称，请键入要完成的名称的前几个字符，然后按*Tab*键。

scandata = rosmessage('sensor_msgs/LaserScan')
%% 
% 创建的消息 |scandata| 通常具有许多与从激光扫描仪接收的数据相关的属性。例如，最小感应距离存储在|RangeMin|属性中，最大感应距离存储在|RangeMax|中。
% 
% 要查看主题和服务可用的所有消息类型的完整列表，请使用<docid:ros_ref.bupf5_j_3 |rosmsg|> |list|。
%% Explore Message Structure and Get Message Data
% ROS消息messages是对象objects，消息数据存储在属性中。MATLAB具有查找和探索消息内容的方便方法。
%% 
% * 如果订阅 |/pose|主 题，则可以接收和检查发送的消息。

posesub = rossubscriber('/pose')
%% 
% 使用<docid:ros_ref.buqbyro |receive|> 从订阅者获取数据。一旦收到新消息，函数将返回该消息并将其存储在|posedata|变量中（第二个参数以秒为单位超时）。

posedata = receive(posesub, 10)
%% 
% 该消息具有 |geometry_msgs/Twist|类型。消息中还有两个其他属性：|Linear| and |Angular|。通过直接访问这些消息属性，可以看到它们的值：

posedata.Linear
%%
posedata.Angular
%% 
% 这些消息字段的每个值实际上都是消息本身。它们的消息类型是|geometry_msgs/Vector3|。|geometry_msgs/Twist|是由两条|geometry_msgs/Vector3|消息组成的复合消息。
% 
% 这些嵌套消息的数据访问与访问其他消息中的数据完全相同。使用以下命令访问线性|Linear|消息的X组件：

xpos = posedata.Linear.X
%% 
% 如果要快速摘要消息中包含的所有数据，请调用<docid:ros_ref.buqb0sj |showdetails|> 函数。showdetails可处理任何类型的消息，并递归显示所有消息数据属性。

showdetails(posedata)
%% 
% |showdetails| 在调试期间以及希望快速浏览消息message内容时帮助您。
%% Set Message Data
% 你也可以设置消息属性值。使用|eometry_msgs/Twist|类型创建消息。

twist = rosmessage('geometry_msgs/Twist')
%% 
% 默认情况下，此消息的数值属性初始化为0。您可以修改此邮件的任何属性。将|Linear|.Y项设置为5。

twist.Linear.Y = 5;
%% 
% 查看消息数据以确保更改生效。

twist.Linear
%% 
% 一旦消息填充了您的数据，您就可以将其用于发布者、订阅者和服务。See the <docid:ros_ug.mw_fa34dc6f-351e-4ab5-8680-46563496814b 
% Exchange Data with ROS Publishers and Subscribers> and <docid:ros_ug.mw_70dbf089-5821-4e67-b96f-f659aea10c0c 
% Call and Provide ROS Services> examples.
%% Copy Messages
% 复制消息message内容有两种方法：
%% 
% * 您可以创建引用副本_reference copy_，而原始message共享相同的数据。
% * 你可以创建一个深副本_deep copy_。副本和原始消息都有自己的数据的深层副本。
%% 
% 如果要在不同的函数或对象之间共享消息数据，则引用副本reference copy很有用，而如果需要消息的独立引用independent copy，则需要深拷贝。
% 
% 使用=符号制作消息的引用副本_reference copy_。这将创建一个引用与原始变量相同的消息内容的变量。

twistCopyRef = twist
%% 
% 修改|twistCopyRef|的|Linear.Z|字段。这也会更改|twist|的内容。

twistCopyRef.Linear.Z = 7;
twist.Linear
%% 
% 制作|twist|的深层副本deep copy，以便在不影响原始数据的情况下更改其内容。使用|copy函数|生成新消息|twistCopyDeep|：

twistCopyDeep = copy(twist)
%% 
% 修改|twistCopyDeep|的 |Linear.X| 属性。|twist|的内容保持不变。

twistCopyDeep.Linear.X = 100;
twistCopyDeep.Linear
twist.Linear
%% Save and Load Messages
% 您可以保存messages并存储内容以供以后使用。
% 
% 从订阅者subscriber获取新消息message。

posedata = receive(posesub,10)
%% 
% 使用MATLAB的Save函数将姿势数据保存到MAT文件中。

save('posedata.mat','posedata')
%% 
% 在将文件加载回工作区之前，请清除posedata变量。

clear posedata
%% 
% 现在可以通过调用<docid:matlab_ref.btm0etn-1 |load|> 函数来加载消息数据。这将|posedata|从上面加载到|messageData|结构中。|posedata|是结构的数据字段。

messageData = load('posedata.mat')
%% 
% 检查 |messageData.posedata|以查看消息内容。

messageData.posedata
%% 
% 你现在可以删除MAT文件。

delete('posedata.mat')
%% Object Arrays in Messages
% 一些来自ROS的消息存储在对象数组<docid:matlab_doccenter.buwib_4-1 object arrays>中。必须以不同于典型数据数组的方式处理这些数据。
% 
% 在您的工作区中，变量|tf|包含一个示例消息。（|exampleHelperROSCreateSampleNetwork|脚本创建了变量。）在本例中，它是用于坐标转换的|tf/tfMessage|类型的消息。

tf
%% 
% |tf|有两个字段：|MessageType|包含标准数据数组，|Transforms|包含对象数组。有53个对象存储在转换|Transforms|中，并且它们都具有相同的结构。
%% 
% 在|Transforms|中展开|tf|以查看结构：

tf.Transforms
%% 
% 变换|Transforms|中的每个对象都有四个属性。可以展开以查看变换的变换字段。 You can expand to see the |Transform| 
% field of |Transforms|.
% 
% |tformFields = tf.Transforms.Transform|
% 
% *注意：*命令输出返回53个单独的答案，因为每个对象都被计算并返回其转换|Transform|字段的值。此格式并不总是有用的，因此可以使用以下命令将其转换为元胞数组cell 
% array：

cellTransforms = {tf.Transforms.Transform}
%% 
% 这会将所有53个对象项放入元胞数组中，使您能够通过索引访问它们。
%% 
% 此外，您可以访问对象object数组元素，就像访问标准的MATLAB向量一样：

tf.Transforms(5)
%% 
% 访问列表53中第五个transform的平移组件：

tf.Transforms(5).Transform.Translation
%% Shut Down ROS Network
% 从ROS网络中删除示例节点、发布者和订阅者。

exampleHelperROSShutDownSampleNetwork
%% 
% 关闭ROS master并删除全局节点global node。

rosshutdown
%% Next Steps
%% 
% * See <docid:ros_ug.mw_f993bbbe-25de-434f-bfd0-e5243256b23c Work with Specialized 
% ROS Messages> for examples of handling images, point clouds, and laser scan 
% messages.
% * For application examples, see the <docid:ros_ug#mw_9c45a664-ab3d-48a5-a65a-52913b8532b5 
% Get Started with Gazebo and a Simulated TurtleBot> or <docid:ros_ug.mw_c9b2d3c3-0e9c-4222-8294-1453212e9813 
% Get Started with a Real TurtleBot> examples.
%% 
% _Copyright 2014-2016 The MathWorks, Inc._
% 
%
##### SOURCE END #####
-->
</div></body></html>